-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Add typing annotation to IntervalIndex.intersection #26870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #26870 +/- ##
==========================================
- Coverage 91.87% 91.86% -0.01%
==========================================
Files 180 180
Lines 50716 50716
==========================================
- Hits 46594 46590 -4
- Misses 4122 4126 +4
Continue to review full report at Codecov.
|
pandas/core/indexes/interval.py
Outdated
@@ -1140,7 +1140,7 @@ def overlaps(self, other): | |||
|
|||
@Appender(_index_shared_docs['intersection']) | |||
@SetopCheck(op_name='intersection') | |||
def intersection(self, other, sort=False): | |||
def intersection(self, other, sort: bool = False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add typing on other? (and do this for all the intersection calls)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try something as follows in HEAD~1:
def intersection(self,
other: IntervalIndex,
sort: bool = False
) -> IntervalIndex:
But this will run into the NameError, i.e.,
NameError: name 'IntervalIndex' is not defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the string Intervalndex and this will work
@@ -1140,7 +1140,10 @@ def overlaps(self, other): | |||
|
|||
@Appender(_index_shared_docs['intersection']) | |||
@SetopCheck(op_name='intersection') | |||
def intersection(self, other, sort=False): | |||
def intersection(self, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typing nitpick, we use single quotes on these annotations, otherwise lgtm. ping on green.
@WillAyd can we systematically check this?
thanks @makbigc |
Follow up #26225 (review)